Skip to content

Apps contract 1: device re-read after app changes; Add discloses the chosen channel's release - #1345

Merged
evanrbowers merged 2 commits into
apps-contract-1from
ac1/codex-fixes
Nov 17, 2026
Merged

evanrbowers merged 2 commits into
apps-contract-1from
ac1/codex-fixes

Conversation

@evanrbowers

Copy link
Copy Markdown
Contributor

Fixes two findings Codex raised on #1344 (apps-contract-1 into device-trust).

An app change reads its device again; a service's ports are the device's

A port setting moved the service's port in graphql (setAppSetting re-applies the app's service before it answers), but only useDeviceApps re-read the apps. The device in the store (DeviceContext.device.services) kept the old port, so the app's page showed the new port while Open terminal (AppTerminalAction, servicePort(device, …)) connected to the old one. The same stale device fed the service row's terminal button, the connect panel and Open (which goes through the service's connect page).

  • useDeviceApps reads the device again with devices.fetchSingleFull({ id, accountId, hidden: true, silent: true }) after a port setting and after any app change that went through (enable, disable, add, remove, channel, pin). Those can add, remove or move the app's services, and while a service stays online no device event says so. Callers pass the device's accountId so the device is re-read under the account it was loaded for.
  • One source of truth: the device's services. Every connection path (service rows, connect panel, Open, Open terminal) already reads where a service listens from IDevice.services, and only the app's page read DeviceAppService.ports. Switching the connection paths to graphql's app view would still leave the service list and connect panel on the device. So the app's page now reads its services' ports from the device too, and DeviceAppService.ports is no longer queried. The apps re-read after a port setting is gone because nothing reads that copy now.

Add an app: what the chosen channel's releases ask

The Add dialog sent the chosen channel but disclosed CatalogApp.root/capabilities, which describe the account's channel's release. addAsks (helpers/appsHelper) resolves the releases an add gives the way graphql does (releaseFor, channelVersion):

  • the pin;
  • else the chosen channel's (the account's where none is chosen, else stable): the candidate goes to the devices in its share and the current to the rest. A channel naming no release gives stable's, and a withdrawn release is given to no device.

Root and capabilities are what those releases ask together, each as CatalogApp.releases lists it. A release missing from the releases read (only the newest 50 are) falls back to the app's own fields, as useReleaseAsks already does. graphql still refuses an add whose consent doesn't cover its release. The API has every field this needs (CatalogApp.channels { current candidate share }, releases { root capabilities withdrawn }).

The consent is now stored with what it was given for (target, product, releases). Changing the channel, pin, target or product unticks it.

Follow-up (not in this PR)

graphql on device-trust asks consentRoot for any release whose manifest declares capabilities, not only root ones (asksConsent in app-catalog.ts; device-apps.ts refuses "asks for … takes consentRoot"). The portal still asks a yes for root releases only. A restricted app that declares person-certificates or ssh-exec is shown with its capabilities but no checkbox, in this dialog and in useAppSwitch, so graphql would refuse that add or enable.

Tests

  • useDeviceApps.test: device re-read after a port setting (service's or listener's), after an enable that went through; not after a non-port setting, a refused change or a refused setting.
  • appsHelper.test (addAsks): account channel, chosen channel, candidate share, stable fallback, pin, withdrawn, release not read.
  • AppAddDialog.test: beta's capabilities disclosed, a root candidate asks the yes and passes channel + consentRoot; the yes is invalidated by channel, pin and target changes.
  • DeviceAppPage.test: service ports from the device.
  • Full frontend suite (217 files, 2157 tests), npm run typecheck, and npm run i18n:extract (no catalog changes) all pass.

🤖 Generated with Claude Code

evanrbowers and others added 2 commits November 17, 2026 11:06
…'s ports are the device's

An app's services are its device's services, and every part of the portal that
connects to one (its row's terminal button, its connect panel, Open, Open
terminal on the Apps section and the app's page) reads where it listens from
the device in the store. A port setting moved the port in graphql, and only the
apps were read again: the app's page showed the new port while Open terminal
connected to the old one until some other device refresh.

useDeviceApps now reads the device again (devices.fetchSingleFull, under the
device's account) after a port setting and after any app change that went
through, since enabling, disabling, removing or moving an app to another
release can add, remove or move its services with no event saying so while the
service stays online. The app's page reads its services' ports from the device
too, so DeviceAppService.ports, a second copy of the same fact, is no longer
asked for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nly for that choice

The Add dialog sent the channel chosen but disclosed what the account's channel's
release asks (CatalogApp.root and capabilities), so choosing beta where beta's
release asks ssh-exec, or runs as root, never said so. addAsks (appsHelper)
resolves the releases an add gives as graphql does (releaseFor, channelVersion):
the pin; else the chosen channel's, the account's where none is: its candidate
to the devices in its share and its current to the rest, a channel naming none
giving stable's, a withdrawn release none. Root and capabilities are what those
releases ask together, each as CatalogApp.releases lists it; one not among the
releases read asks what the app's own fields say, graphql refusing an add whose
consent does not cover its release.

The yes is kept with what it was given for (target, product, releases): another
channel, pin, target or product asks it again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@evanrbowers

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T19:08:49.036717Z d96c1ea Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: d96c1ea38e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@evanrbowers
evanrbowers merged commit 01831f0 into apps-contract-1 Nov 17, 2026
2 checks passed
@evanrbowers
evanrbowers deleted the ac1/codex-fixes branch November 17, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant